package com.yj.dao.impl;

import org.springframework.stereotype.Repository;

import com.yj.dao.UserDao;
import com.yj.model.Admin;
import com.yj.model.Student;
import com.yj.model.Teacher;

@Repository("userDao")
public class UserDaoImpl extends BaseDaoImpl<Object> implements UserDao {

	@Override
	public Student studentLogin(Student student) {
		String hql = "from Student s where s.id=:id and s.password=:password";
		return (Student)getSession().createQuery(hql).setParameter("id", student.getId()).setParameter("password", student.getPassword()).uniqueResult();
	}


	@Override
	public Teacher teacherLogin(Teacher teacher) {
		String hql = "from Teacher t where t.id=:id and t.password=:password";
		return (Teacher)getSession().createQuery(hql).setParameter("id", teacher.getId()).setParameter("password", teacher.getPassword()).uniqueResult();
	}


	@Override
	public Admin adminLogin(Admin admin) {
		String hql = "from Admin a where a.id=:id and a.password=:password";
		return (Admin)getSession().createQuery(hql).setParameter("id", admin.getId()).setParameter("password", admin.getPassword()).uniqueResult();
	}



}
